package com.zynn.service.module.canal.receiver;

import com.zynn.common.core.utils.TypeConvertUtil;
import com.zynn.feign.module.es.SyncUserFeignService;
import com.zynn.message.queue.constant.MqQueueNameConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 *
 * @author jerry-liqi
 *
 * 同步用户信息到ES
 *
 * @deprecated
 */
@Component
@Slf4j
public class SynEsReceiver {

    @Autowired
    private SyncUserFeignService syncUserFeignService;

    /**
     * 同步用户的更新信息到ES
     *
     * @param columnsMap
     */
    @JmsListener(destination = MqQueueNameConstant.SYN_ES_USERS)
    public void receiveEventLikeQueue(Map<String, Object> columnsMap) {
        log.info("SYN_ES_USERS:{}", columnsMap);
        Long userId = TypeConvertUtil.objectToLong(columnsMap.get("userid"));
        String nickName = TypeConvertUtil.objectToString(columnsMap.get("unickname"));
        int sex = TypeConvertUtil.objectToInteger(columnsMap.get("usex"));
        String headPic = TypeConvertUtil.objectToString(columnsMap.get("upic"));
        syncUserFeignService.syncUser(userId, nickName, sex, headPic);
    }
}